package tests;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.*;
import org.openqa.selenium.internal.seleniumemulation.Click;
import org.openqa.selenium.firefox.*;

import common.ReadPageXML;
import pages.GoogleSearchPage;
import pages.GoogleSearchResultsPage;

public class TestOne {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		//WebDriver driver = new HtmlUnitDriver();
		GoogleSearchPage cGoogleSearchPage = new GoogleSearchPage();
		GoogleSearchResultsPage cGoogleSearchResultsPage = new GoogleSearchResultsPage();
		
		// About page test case
		
		WebDriver driver = new FirefoxDriver(); // new HtmlUnitDriver();
		driver.get("http://www.google.com");
		//WebElement element = driver.findElement(By.name("q"));
		WebElement element = driver.findElement(By.name(cGoogleSearchPage.getGoogleSearch()));

		element.sendKeys("Potato!");
		element.click();
		element.submit();
		
		System.out.println("Page title is: " + driver.getTitle());
		System.out.println("Current page url is " + driver.getCurrentUrl());
		System.out.println("getResultsStats = " + cGoogleSearchResultsPage.getResultStats());

		try {
		Thread.sleep(1000);
		} catch(InterruptedException e) {
			
		}
		
		WebElement ele1 = driver.findElement(By.id(cGoogleSearchResultsPage.getOptionsButtonIcon()));
		if (ele1.isDisplayed()) {
			System.out.println("Success!!!");
		} else {
			System.out.println("Failure!!!");
		}
		if (driver.findElement(By.id(cGoogleSearchResultsPage.getOptionsButtonIcon())).isDisplayed()) {
			System.out.println("Success!!!");
		} else {
			System.out.println("Failure!!!");
		}
		driver.quit();
	}
}
